home *** CD-ROM | disk | FTP | other *** search
/ Aminet 13 / Aminet 13 - August 1996.iso / Aminet / dev / e / StringNode.lha / stringnode / examples / StringNode_Example2.e < prev    next >
Text File  |  1996-01-08  |  2KB  |  59 lines

  1. /*
  2. ** StringNode Example-2
  3. **
  4. ** add(), del(), first(), succ() AND last() methods.
  5. **
  6. ** (C)Copyright 1995 Fabio Rotondo
  7. **
  8. ** e-mail: fosft@intercom.it
  9. */
  10.  
  11. MODULE 'fabio/StringNode_oo',   -> Our MAGIC MODULE
  12.        'tools/exceptions'
  13.  
  14. PROC main()  HANDLE
  15.   DEF n:PTR TO stringnode      -> This is our OBJECT instance
  16.  
  17.   NEW n.stringnode()           -> OBJECT initialization
  18.  
  19.   n.add('Zorro')              -> Here we add some items...
  20.   n.add('Batman')
  21.   n.add('Superman')
  22.   n.add('Gold Drake')
  23.   n.add('Mandrake')
  24.   n.add('MOMMY')
  25.  
  26.   shwall(n)                   -> Here we see them
  27.  
  28.   n.first()                   -> This method should be checked agains FALSE...
  29.   n.del()                     -> It is DEAD!
  30.   shwall(n)                   -> Show Results
  31.  
  32.   n.succ()                    -> Two items later... (The first killed...)
  33.   n.del()                     -> Another Kill!
  34.   shwall(n)                   -> Show Results
  35.  
  36.   n.last()                    -> The last item
  37.   n.del()                     -> Is DEAD too!
  38.   WriteF('Last:\s\n', n.obj()) -> Now this is the last
  39.   shwall(n)
  40.  
  41. EXCEPT DO
  42.   report_exception()
  43.   END n                       -> Remember ALWAYS TO end an OBJECT
  44.   CleanUp(0)
  45. ENDPROC
  46.  
  47. PROC shwall(n:PTR TO stringnode)
  48.   WriteF('------- \d ----------\n', n.numitems())
  49.  
  50.   IF n.first()                      -> Here we go TO the first node item
  51.     REPEAT
  52.       WriteF('Node:\s\n', n.obj()) -> Node STRING...
  53.     UNTIL n.succ() = FALSE          -> LOOP UNTIL the end
  54.   ELSE
  55.     WriteF('No Nodes in LIST...\n')
  56.   ENDIF
  57. ENDPROC
  58.  
  59.